<template>
  <div class="login-body">
    <el-form :model="loginFrom" status-icon :rules="rules" label-width="100px" ref="loginFromRef" class="login-from">
    <el-form-item label="username" prop="username">
      <el-input v-model="loginFrom.username" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item label="password" prop="password">
      <el-input type="password" v-model="loginFrom.password" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button @click="resetForm('loginFrom')">reset</el-button>
      <el-button type="primary" @click="clickLoginBtn">login</el-button>
    </el-form-item>
  </el-form>
  </div>
</template>

<script>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { useLoginEffect,useLoginValidate } from './login-hooks'
export default {
  setup(){
    let loginFromRef = ref(null)
    const router = useRouter()
    const { loginFrom,clickLoginBtn } = useLoginEffect(loginFromRef,router)
    const { rules,resetForm } = useLoginValidate(loginFromRef) 
    return {
      loginFrom,
      rules,
      loginFromRef,
      resetForm,
      clickLoginBtn
    }
  }
}
</script>

<style>
.login-body{
  height: 100vh;
  min-width: 900px;
  background-image: radial-gradient(circle,#99CCCC, #7171B7);
}
.login-from{
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
}
</style>